package fun.yao.common.queue;

import java.nio.ByteBuffer;

public class FileCacheQueueByteBuffer extends AFileCacheQueue
{

    public FileCacheQueueByteBuffer()
    {
        super();
    }

    public FileCacheQueueByteBuffer(int iMaxSize)
    {
        super(iMaxSize);
    }

    public void add(ByteBuffer msg) throws Exception
    {
        super.addObject(msg);
    }

    public ByteBuffer pool() throws Exception
    {
        return (ByteBuffer)super.pollObject(true);
    }

    public ByteBuffer peek() throws Exception
    {
        return  (ByteBuffer)super.pollObject(false);
    }

    @Override
    protected byte[] transforToBytes(Object obj) throws Exception
    {
        return ((ByteBuffer)obj).array();
    }

    @Override
    protected Object transforToObject(byte[] msg) throws Exception
    {
        return ByteBuffer.wrap(msg);
    }

}
